= javascript_include_tag "#{STRIPE_JS_HOST}/v3/"
- if presenter.stripe_account_ready
  - if presenter.stripe_bank_account_ready
    .row
      .col-12
        - if presenter.stripe_account_verified?
          %h3.paypal-account-connected
            =icon_tag("check", ["icon-fix"])
            =t("stripe_accounts.stripe_bank_connected")
          %p
            =t("stripe_accounts.stripe_can_accept")
        - elsif presenter.stripe_account_restricted?
          %h3.paypal-account-disabled
            =icon_tag("cross", ["icon-fix"])
            =t("stripe_accounts.stripe_account_restricted")
          %p
            =t("stripe_accounts.stripe_account_restricted_info")
        - elsif presenter.stripe_account_restricted_soon?
          %h3.stripe-account-restricted-soon
            =icon_tag("minus", ["icon-fix"])
            =t("stripe_accounts.stripe_account_restricted_soon")
          %p
            =t("stripe_accounts.stripe_account_restricted_soon_info")
        - elsif presenter.stripe_account_pending_verification?
          %h3.stripe-account-pending-verification
            =icon_tag("check", ["icon-fix"])
            =t("stripe_accounts.stripe_account_pending_verification")
          %p
            =t("stripe_accounts.stripe_account_pending_verification_info")

    - unless presenter.stripe_account_pending_verification?
      .row
        = link_to t("stripe_accounts.form_new.edit"), "#", id: "edit-stripe-info"
  - elsif !presenter.paypal_enabled
    .row
      .col-12
        %h3= t("payment_settings.credit_card")
        %p
          = t("payment_settings.credit_card_bank_details")
        %p
          = link_to t("payment_settings.add_bank_details"), '#', id: "edit-stripe-info"


  %div.hidden#stripe_forms
    .row.paypal-wizard.connect-row
      .col-12
        .paypal-wizard-content.connect-row
          = form_tag update_person_payment_settings_path(@current_user),
            id: "stripe-account-form", multipart: true, method: :put do
            = render 'stripe_name', presenter: presenter
            = render 'address_fields_form', presenter: presenter
            = render 'bank_fields_form', presenter: presenter
            = render 'verification_fields_form2', presenter: presenter

            .col-4
              = link_to t('stripe_accounts.form_new.cancel'), person_payment_settings_path(@current_user), style: 'float: right; margin-top: 1.5em'
              = button_tag t('stripe_accounts.form_new.save_details')
  - content_for :extra_javascript do
    :javascript
      $(function(){ 
      $("#edit-stripe-info").click(function(){
        $("#stripe_forms").toggleClass("hidden");
        $("#edit-stripe-info").hide();
        return false;
      });
      if(#{presenter.stripe_account[:stripe_bank_id].blank? || flash[:error].present?}) {
        $("#edit-stripe-info").hide();
        $("#stripe_forms").toggleClass("hidden");
      }})
- else
  %p
    = t("stripe_accounts.form_new.need_info")
  .row.paypal-wizard.connect-row
    %div
      .paypal-wizard-content.connect-row
        .col-12
          = form_tag create_person_payment_settings_path(@current_user), id: "stripe-account-form", multipart: true do
            = render 'stripe_name', presenter: presenter
            .country-dependent{"data-country-except" => "XXX"}
              = render 'address_fields_form', presenter: presenter
            .country-dependent{"data-country-except" => "XXX"}
              = render 'bank_fields_form', presenter: presenter
            = render 'personal_id_number', presenter: presenter
            = render 'verification_fields_form2', presenter: presenter

            .country-dependent{"data-country-except" => "XXX"}
              - base_terms_url = "https://stripe.com/COUNTRY/connect-account/legal#translation"
              - stripe_link = link_to t("stripe_accounts.form_new.tos_link_title"), base_terms_url, target: "_blank", data: {terms_url: base_terms_url}, id: "stripe-terms-link"
              = t("stripe_accounts.form_new.tos_link", stripe_link: stripe_link ).html_safe

              = button_tag t('stripe_accounts.form_new.save_details')

- stripe_data = stripe_default_data2.dup
- stripe_data = stripe_data.merge(update: true) if presenter.stripe_account_ready
- content_for :extra_javascript do
  :javascript
    $(function() {
      window.ST.StripeBankForm3.init(#{stripe_data.to_json.html_safe});
    });

